<template>
  <div>
    <!-- 表格 -->
    <el-table :data="seckList" border style="width: 100%">
      <el-table-column prop="title" label="活动名称" width="180">
      </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="item">
          <div>
            <el-tag effect="dark" type="success" v-if="item.row.status == 1">
              启用
            </el-tag>
            <el-tag effect="dark" type="warning" v-else> 禁用 </el-tag>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="item">
          <div>
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-edit"
              @click="edit(item.row.id)"
            ></el-button>
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-delete"
              @click="del(item.row.id)"
            ></el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
import { seckdelete } from "../../require/api";
export default {
  data() {
    return {};
  },
  props: [],
  methods: {
    ...mapActions({
      seckillAction: "seckill/seckillAction",
    }),
    edit(id) {
      // console.log(id);
      this.$emit("edit", id);
    },
    del(id) {
      console.log(id);
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          seckdelete({ id }).then((res) => {
            if (res.code == 200) {
              // 成功提示
              this.$message.success(res.msg);
              // 更新页面
              this.seckillAction();
            } else {
              // 失败提示
              this.$message.error(res.msg);
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
  computed: {
    ...mapState("seckill", ["seckList"]),
  },
  mounted() {
    this.seckillAction();
  },
};
</script>
<style lang=less scoped >
</style>
